﻿using System;
using System.ComponentModel;
using System.Windows;
namespace WPFExcelReport
{
    public partial class TSZL02
    {

        public TSZL02()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VICC_ZLAN();
            this.DataContext = MV;
            InitializeComponent();
        }
        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            if (IsLoaded)
                return;
            base.Window_Loaded(sender, e);
            LOADALL();
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            if (app.User.Trim() == "ITXV")
            {
                if (dwMaster != null)
                {
                    switch (TMV.DEVTYP.Trim())
                    {
                        case "FXPLC":
                            ZP0 = "0";
                            ZP1 = "1190";
                            ZP2 = "8";
                            DATASEND = "22,33,44";
                            break;
                        case "S7200":
                            ZP0 = "Q";
                            ZP1 = "0.0";
                            ZP2 = "1";
                            DATASEND = "1";
                            break;
                        case "YHA12":
                            ZP0 = "R";
                            ZP1 = "0.0";
                            ZP2 = "1";
                            DATASEND = "1";
                            break;
                    }
                }
            }
        }
        public void LOADALL()
        {
            dwData = TBMain.NewRow();
            dwData["MANDANT"] = app.Mandant;
            SResult = TMV.QICC_ZLAN03(dwData);
            MergeData(SResult, false);
        }
        public override void LOADBYAUF()
        {
            filter = "LOCALIP='" + ORDERNUM + "'";
            rows = TBMain.Select(filter);
            if(rows.Length==0)
            {
                PLCIP = ORDERNUM;
                LOADALL();
            }
            Locate("LOCALIP", ORDERNUM);
            base.LOADBYAUF();
        }
    }
}